/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

public class Context {
    protected static Context context=null;
    private int var_final;
    private int ultim_parcurs;
    private int suma_ultim;
    
    private Context(){
    this.var_final=0;
    this.ultim_parcurs=0;
    this.suma_ultim=0;
    }
    
    public static Context getContext(){
        if(context==null){
            context=new Context ();
            return context;
        }
        else return context;
    }
    
    
    public int returneazaFinal(){
    var_final=var_final+suma_ultim;
    return var_final;
    }
    
    public void actualizare(int caracter){
        if(caracter<ultim_parcurs){
            var_final=var_final+suma_ultim;
            suma_ultim=caracter;
            ultim_parcurs=caracter;
        }
        else if(caracter==ultim_parcurs){
            suma_ultim=suma_ultim+ultim_parcurs;
        }
        
        else{
            var_final=var_final-suma_ultim;
            suma_ultim=caracter;
            ultim_parcurs=caracter;
            
        }
    }

    public int getUltim_parcurs() {
        return ultim_parcurs;
    }

    public int getSuma_ultim() {
        return suma_ultim;
    }

    public int getVar_final() {
        return var_final;
    }

    public void setSuma_ultim(int suma_ultim) {
        this.suma_ultim = suma_ultim;
    }

    public void setUltim_parcurs(int ultim_parcurs) {
        this.ultim_parcurs = ultim_parcurs;
    }

    public void setVar_final(int var_final) {
        this.var_final = var_final;
    }
    
    
    
    
    
    
    
}

